param([string]$Env = "prod")
Write-Host "=== Starting project compilation (env: $Env) ==="
mvn clean package -P$Env -DskipTests
if ($LASTEXITCODE -ne 0) {
    Write-Host "=== Compilation failed, terminating deployment ===" -ForegroundColor Red
    exit 1
}

Write-Host "`n=== Starting Docker image build ==="
docker-compose build
if ($LASTEXITCODE -ne 0) {
    Write-Host "=== Image build failed, terminating deployment ===" -ForegroundColor Red
    exit 1
}
